<!--
Copyright 2018 The Dopamine Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
//-->

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <script src="https://cdn.jsdelivr.net/npm/vega@3"></script>
  <script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script>
  <script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <style>
    body {
      font-family: sans-serif;
    }

    .vega-actions a {
      padding: 0.2em;
    }
  </style>
</head>

<body>
  <h1>Baseline plots</h1>
  <p>This page provides a quick visualization of the training runs for all our default agents.</p>

  <p>See the <a href="https://github.com/google/dopamine/tree/master/baselines">baselines main page</a> for details on the hyperparameters used.</p>
  <hr>
  <select id="game" name="game_select" onchange="showGame(this)">
  </select>
  <div id="vega_div"></div>
</body>

  <script>
   var games = [
     "airraid",
     "alien",
     "amidar",
     "assault",
     "asterix",
     "asteroids",
     "atlantis",
     "bankheist",
     "battlezone",
     "beamrider",
     "berzerk",
     "bowling",
     "boxing",
     "breakout",
     "carnival",
     "centipede",
     "choppercommand",
     "crazyclimber",
     "demonattack",
     "doubledunk",
     "elevatoraction",
     "enduro",
     "fishingderby",
     "freeway",
     "frostbite",
     "gopher",
     "gravitar",
     "hero",
     "icehockey",
     "jamesbond",
     "journeyescape",
     "kangaroo",
     "krull",
     "kungfumaster",
     "montezumarevenge",
     "mspacman",
     "namethisgame",
     "phoenix",
     "pitfall",
     "pong",
     "pooyan",
     "privateeye",
     "qbert",
     "riverraid",
     "roadrunner",
     "robotank",
     "seaquest",
     "skiing",
     "solaris",
     "spaceinvaders",
     "stargunner",
     "tennis",
     "timepilot",
     "tutankham",
     "upndown",
     "venture",
     "videopinball",
     "wizardofwor",
     "yarsrevenge",
     "zaxxon",
    ];
    function showGame(elem) {
      var selectedGame = elem.value;
      var dataSource = "data/" + selectedGame + ".vg.json";
      vegaEmbed("#" + selectedGame + "_vg", dataSource);
      $(".outer_div").attr("style","display:none");
      document.getElementById(elem.value).style.display = "block";
    }
    $(document).ready(function() {
      console.log("Document loaded.")
      // Add options to drop down.
      var gameSelect = $("#game");
      $.each(games, function(idx, game) {
        gameSelect.append(
            $("<option></option>").val(game).html(game)
        );
      });
      // Lazily create the vega divs
      var vegaDiv = $("#vega_div")
      $.each(games, function(idx, game) {
        var outerDiv = $("<div></div>").attr("id", game).attr("style", "display: none;").addClass("outer_div").appendTo(vegaDiv);
        outerDiv.append($("<h1></h1>").text(game));
        outerDiv.append($("<div></div>").attr("id", game + "_vg"));
      });
      showGame(document.querySelector("option[value=airraid]"));
    });
  </script>
